"""
日志工具
"""

import os
import logging

__all__ = ['logger']

CUR_DIR = os.path.dirname(os.path.abspath(__file__))
LOGS_DIR = os.path.dirname(CUR_DIR) + os.sep + 'logs'

if not os.path.isdir(LOGS_DIR):
	os.mkdir(LOGS_DIR)

# 调试日志设置
logger = logging.getLogger('cloud189')
log_file = LOGS_DIR + os.sep + 'debug-cloud189.log'
fmt_str = "%(asctime)s [%(filename)s:%(lineno)d] %(funcName)s %(levelname)s - %(message)s"
filehandler = logging.FileHandler(filename=log_file, mode='a', encoding="utf-8")

logging.basicConfig(level=logging.DEBUG,
					handlers=[filehandler],
					format=fmt_str,
					datefmt="%Y-%m-%d %H:%M:%S")

logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
